package com.huawei.hwCloudJs.service.jsapi;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.Signature;
import android.util.Log;
import com.huawei.hwCloudJs.d.f;
import com.huawei.hwCloudJs.service.jsapi.bean.BrowserInfo;

public final class a {
    private static final String a = "JsCoreHelper";
    private static a b = new a();

    private a() {
    }

    public static a a() {
        return b;
    }

    public BrowserInfo a(Context context) {
        BrowserInfo browserInfo = new BrowserInfo();
        String packageName = context.getPackageName();
        browserInfo.setBrowserType(packageName);
        browserInfo.setClientVersion(f.a(context, packageName));
        browserInfo.setClientVersionCode(f.b(context, packageName) + "");
        return browserInfo;
    }

    public String a(Context context, String str) {
        String str2 = "";
        PackageManager packageManager = context.getPackageManager();
        if (packageManager != null) {
            try {
                PackageInfo packageInfo = packageManager.getPackageInfo(str, 64);
                if (packageInfo != null) {
                    Signature[] signatureArr = packageInfo.signatures;
                    if (signatureArr != null && signatureArr.length > 0) {
                        str2 = signatureArr[0].toCharsString();
                    }
                }
            } catch (NameNotFoundException e) {
                Log.e(a, "getSign PackageManager.NameNotFoundException");
            }
        }
        return str2;
    }
}
